﻿using Axis.BusinessObject.Core;
using Axis.Dao.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Axis.Web.Views.News
{
    public partial class ucNewsMenu : System.Web.UI.UserControl
    {
        public int CatID { get; set; }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
                lblMenu.Text = GetSubMenu(CatID);
        }
        protected string GetSubMenu(int parentID)
        {
            StringBuilder ret = new StringBuilder();
            string inputValue = string.Format("<InputValue UserID='' Session='' FunctionCode='MenuCategory' ParentID='{0}' />", parentID);
            CCoreDao cCoreDao = new CCoreDao();
            IList<CListData> list = cCoreDao.GetListData(inputValue);
            if (list != null && list.Count > 0)
            {
                foreach (CListData data in list)
                {
                    string href = string.Empty;
                    ret.AppendFormat("<img  submenu='{0}' src='{1}' image-active='{2}' image='{3}' border-color='{4}' />",
                        data.ID, data.DeActiveImage, data.ActiveImage, data.Image, data.BorderColor);
                }
            }
            return ret.ToString();
        }
    }
}